 #include <stdio.h>
 unsigned mod(unsigned a, unsigned b, unsigned c);
 int main()
{
	unsigned int a,b,c,sum;
	printf("Input unsigned integer numbers a, b, c:\n");
	scanf("%u%u%u",&a,&b,&c);

	printf("%u*%u%%%u=%u\n",a,b,c,mod(a,b,c));
	return 0;
}
unsigned mod(unsigned a, unsigned b, unsigned c)
{
	int temp,i=0,str[32];
	unsigned int sum;
	while(i<32)
	{
		temp=((b & (1 << ( i ^ 31 ))) != 0);
		str[i]=temp;
		i++;
	}
	sum=a*str[0];
	for(i=1;i<=31;i++)
	{
		sum=sum*2%c+a*str[i];
	}
	return sum%c;
}

